package org.xtframe.common;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xtframe.bean.SystemConfig;
import org.xtframe.entity.ServerData;

public class SystemInitializing extends HttpServlet {

	private static final long serialVersionUID = -186278965583002371L;
	private final Log logger = LogFactory.getLog(getClass());

	public void destroy() {
		super.destroy();
	}

	public void init() throws ServletException {
		ServerData serverData = new ServerData();
		if(serverData.initAll()) {
			ServletContext application = this.getServletContext();
			application.removeAttribute(SystemConfig.SERVER_DATA);
			application.setAttribute(SystemConfig.SERVER_DATA, serverData);
			logger.info("xtFrame系统初始化成功！");
		}
		else {
			logger.info("xtFrame系统初始化失败！");
		}
	}
}
